#pragma once

#include <algorithm>
#include "vtkActorCollection.h"

enum class BooleanOP
{
	Union,
	Intersect,
	Subtract
};

namespace Colors
{
	// 背景颜色
	static double Background[3] = { 0.75,0.75,0.75 };
	// Actor确认创建
	static double ActorCreated[3] = { 1,0.64453125,0 };
	static double ActorSelected[3] = { 0.0,1.0,0.0 };
	static double ActorHover[3] = { 1,0,0 };
}

static bool IsNearlyEqual(double a, double b)
{
	return std::abs(a - b) < 1e-6;
}

static bool IsNearlyEqual(float a, float b)
{
	return std::abs(a - b) < 1e-6;
}

static bool IsNearlyEqual(float a, double b)
{
	return std::abs(double(a) - b) < 1e-6;
}

static bool IsNearlyEqual(double a, float b)
{
	return std::abs(a - double(b)) < 1e-6;
}

static bool IsNearlyZero(double a)
{
	return std::abs(a) < 1e-6;
}

static bool IsNearlyZero(float a)
{
	return std::abs(a) < 1e-6;
}

static bool ContainsActor(std::vector<Handle(QIVtkSelectionPipeline)> actorCollection, Handle(QIVtkSelectionPipeline) actorToFind)
{
	// 遍历查找
	for (auto actor : actorCollection)
	{
		if (actor == actorToFind)
		{
			return true; // 找到了
		}
	}
	return false; // 未找到
}

static void RemoveActor(std::vector<Handle(QIVtkSelectionPipeline)> actorCollection, Handle(QIVtkSelectionPipeline) actorToRemove)
{
	actorCollection.erase(std::remove(actorCollection.begin(), actorCollection.end(), actorToRemove), actorCollection.end());
}
